package com.ymatou.iapi.godmch.testcase;

import com.shop2cn.iapi.member.parameter.CreateMemberBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.listCSBean;
import com.ymatou.iapi.godmch.parameter.mchCreateCsBean;
import com.ymatou.iapi.godmch.service.listCSCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodMemberService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.cs_info;
import com.ymttest.database.model.godmch.buyer_invite_code;
import com.ymttest.database.model.godmch.buyer_invite_codeExample;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
import com.ymttest.database.sqlwapper.godmch.buyer_invite_codeWapper;
import com.ymttest.utils.TestDataManager;

import org.junit.*;
import org.junit.experimental.categories.Category;
import org.springframework.context.annotation.Bean;

/**
 * 查看客服列表 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_listCS {
	private static listCSBean listcsBean;
	private static listCSCall listcsCall;
	DefGodMchWapper DefGodMchWapper;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查看客服列表");
	}

	@Before
	public void caseUp() {
		listcsBean = new listCSBean();
		listcsCall = new listCSCall();
		DefGodMchWapper = new DefGodMchWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(listcsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

//	@Test
//	public void Tc_CreateCs() {
//		Logger.start(true, "创建数据,不跑case");
//		try {
//			Integer templateId = 6;
//			int mchId = AgentUsers.vipAgentUserId1;
//			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
//			int csId = DGUserCallService.UserCreateCall(usercreateBean);
//			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
//			String AccessToken = AuthCallServiceV2.createToken(csId, DGUserCallService.DG_SellerWxApp.toString());
//			Logger.debug("mid:"+mchId+":csid:"+csId +":templateId:"+templateId+ ":token:" + AccessToken);
//		} catch (Exception e) {
//			// TODO: handle exception
//		}
//	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_001() {
		Logger.start(true, "查看客服列表,返回成功");
		try {
			Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
			Logger.comment("创建渠道商客服:" + csId);
			
			GodmchManageCallService.EditCsRemark(mchId, csId, "remakr1");
			listcsBean.setMchId(mchId);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
				//	csi = DefGodMchWapper.selectCsInfo(csb.getMchId(), csb.getCsId()).get(0);
					csi = DefGodMchWapper.selectCsInfo(mchId, csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					
					Logger.verifyEquals(csb.getSetPwd(), false, "验证setPwd");
					Logger.verifyEquals(csb.getTitle(), "", "验证title");
					
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
					
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_001_1() {
		Logger.start(true, "查看客服列-主动添加客服,templateId不为空返回成功");
		try {
			Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
			Logger.comment("创建渠道商客服:" + csId);
			GodmchManageCallService.EditCsRemark(mchId, csId, "remakr1");
			listcsBean.setMchId(mchId);
			listcsBean.setTemplateId(1);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
				//	csi = DefGodMchWapper.selectCsInfo(csb.getMchId(), csb.getCsId()).get(0);
					csi = DefGodMchWapper.selectCsInfo(mchId, csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					
					Logger.verifyEquals(csb.getSetPwd(), false, "验证setPwd");
					Logger.verifyEquals(csb.getTitle(), "", "验证title");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_001_2() {
		Logger.start(true, "查看客服列-主动添加客服,title不为空返回成功");
		try {
			mchCreateCsBean mchCreateCsBean=GodmchManageCallService.initMchCreateCsBean();
			GodmchManageCallService.mchCreateCsCall(mchCreateCsBean);
			
			cs_info csi2=new DefGodMchWapper().selectCsInfoByMchId(mchCreateCsBean.getMchId()).get(0);
			
			Integer mchId=mchCreateCsBean.getMchId();
			
			Logger.comment("创建渠道商客服:" + csi2.getCsId());
			
			listcsBean.setMchId(mchId);
			listcsBean.setTitle(mchCreateCsBean.getTitle());
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
				//	csi = DefGodMchWapper.selectCsInfo(csb.getMchId(), csb.getCsId()).get(0);
					csi = DefGodMchWapper.selectCsInfo(mchId, csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证TemplateTitle");
					
					Logger.verifyEquals(csb.getSetPwd(), true, "验证setPwd");
					Logger.verifyEquals(csb.getTitle(), mchCreateCsBean.getTitle(), "验证title");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
					
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_002() {
		Logger.start(true, "查看客服列表,翻页成功");
		try {
			int p = 5;// 验证5页
			Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			for (int i = 0; i < p; i++) {
				UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
				int csId = DGUserCallService.UserCreateCall(usercreateBean);
				GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
				Logger.comment("创建渠道商客服:" + csId);
			}
			for (int i = 0; i < p; i++) {
				listcsBean.setMchId(mchId);
				listcsBean.setPageIndex(i + 1);
				listcsBean.setPageSize(1);
				listcsCall.setData(listcsBean);
				listcsCall.callService();
				Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
				listcsCall.getCsBaseVo().forEach(csb -> {
					cs_info csi;
					try {
						csi = DefGodMchWapper.selectCsInfo(mchId, csb.getCsId()).get(0);
						Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//	Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
						String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
						Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
						Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				});
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_003() {
		Logger.start(true, "查看客服列表,多条记录成功");
		try {
			int p = 5;// 验证5页
			Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			for (int i = 0; i < p; i++) {
				UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
				int csId = DGUserCallService.UserCreateCall(usercreateBean);
				GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
				Logger.comment("创建渠道商客服:" + csId);
			}
			listcsBean.setMchId(mchId);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(4);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(listcsBean.getPageSize(), listcsCall.getCsBaseVo().size(), "验证单分页条数记录");
			Logger.verifyEquals(p, listcsCall.getJsonObject().get("result").getAsJsonObject().get("total").getAsInt(), "验证total");
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
					csi = DefGodMchWapper.selectCsInfo(mchId, csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
				//	Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_004() {
		Logger.start(true, "查看客服列表,pageindex0失败");
		try {
			listcsBean.setMchId(500003758);
			listcsBean.setPageIndex(0);
			listcsBean.setPageSize(1);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			//这里目前是兼容模式 不传或者0默认第一页5条
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
					//csi = DefGodMchWapper.selectCsInfo(csb.getMchId(), csb.getCsId()).get(0);
					csi = DefGodMchWapper.selectCsInfo(listcsBean.getMchId(), csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_005() {
		Logger.start(true, "查看客服列表,pagesize0失败");
		try {
			listcsBean.setMchId(500003758);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(0);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			//这里目前是兼容模式 不传或者0默认第一页5条
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
					csi = DefGodMchWapper.selectCsInfo(listcsBean.getMchId(), csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_006() {
		Logger.start(true, "查看客服列表pageIndex=100,pageSize=10,返回空");
		try {
			Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
			Logger.comment("创建渠道商客服:" + csId);

			listcsBean.setMchId(mchId);
			listcsBean.setPageIndex(100);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(0, listcsCall.getCsBaseVo().size(), "验证size");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_007() {
		Logger.start(true, "查看客服列表,验证商户id不存在,返回空结果");
		try {
			listcsBean.setMchId(-1);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(1);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(0, listcsCall.getCsBaseVo().size(), "验证size");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_008() {
		Logger.start(true, "不输入商户id,返回错误");
		try {
			// listcsBean.setMchId(1);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(1);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("4001", listcsCall.getString("status"), "验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_009() {
		Logger.start(true, "不输入pagesize,返回错误");
		try {
			listcsBean.setMchId(1);
			listcsBean.setPageIndex(1);
			// listcsBean.setPageSize(1);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(0, listcsCall.getCsBaseVo().size(), "验证size");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_010() {
		Logger.start(true, "不输入pateindex,不返回数据");
		try {
			listcsBean.setMchId(1);
			// listcsBean.setPageIndex(1);
			listcsBean.setPageSize(1);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(0, listcsCall.getCsBaseVo().size(), "验证size");
//			listcsCall.getCsBaseVo().forEach(csb -> {
//				cs_info csi;
//				try {
//					csi = DefGodMchWapper.selectCsInfo(csb.getMchId(), csb.getCsId()).get(0);
//					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
//					Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
//					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
//					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
//				} catch (InterruptedException e) {
//					e.printStackTrace();
//				}
//			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_011() {
		Logger.start(true, "查看客服列表,邀请制客服-返回成功(新增 20200610)");
		try {
			Integer templateId = 11;
			int mchId=GodmchManageCallService.CreateSellerMch();
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
			Logger.comment("创建渠道商客服:" + csId);
			//设置商户是邀请制
		    GodMemberService.setCollectionMobile(mchId, true);
            GodMemberService.setInvitationCodeCall(mchId, true, 0);
            
			GodmchManageCallService.EditCsRemark(mchId, csId, "remakr1"); 
			listcsBean.setMchId(mchId);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
					csi = DefGodMchWapper.selectCsInfo(listcsBean.getMchId(), csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					
					Logger.verifyEquals(csb.getSetPwd(), false, "验证setPwd");
					Logger.verifyEquals(csb.getTitle(), "", "验证title");
					//邀请码
					buyer_invite_codeExample example=new buyer_invite_codeExample();
					example.createCriteria().andUserIdEqualTo(csId);
					buyer_invite_codeWapper codeMapper=new buyer_invite_codeWapper();
					buyer_invite_code code=codeMapper.selectByExample(example).get(0);	
					Logger.verifyEquals(csb.getInviteCode(), code.getInviteCode(), "验证inviteCode");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_011_1() {
		Logger.start(true, "查看客服列表,邀请制客服-返回成功(新增 20200610)");
		try {
//			Integer templateId = 11;
//			int mchId=GodmchManageCallService.CreateSellerMch();
//			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
//			int csId = DGUserCallService.UserCreateCall(usercreateBean);
//			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
//			Logger.comment("创建渠道商客服:" + csId);
//			//设置商户是邀请制
//		    GodMemberService.setCollectionMobile(mchId, true);
//            GodMemberService.setInvitationCodeCall(mchId, true, 0);
//            
//			GodmchManageCallService.EditCsRemark(mchId, csId, "remakr1"); 
			listcsBean.setMchId(501127949);
			//listcsBean.setLoginId("500933794");
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
					csi = DefGodMchWapper.selectCsInfo(listcsBean.getMchId(), csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					
					Logger.verifyEquals(csb.getSetPwd(), false, "验证setPwd");
					Logger.verifyEquals(csb.getTitle(), "", "验证title");
					//邀请码
					buyer_invite_codeExample example=new buyer_invite_codeExample();
					example.createCriteria().andUserIdEqualTo(csb.getCsId());
					buyer_invite_codeWapper codeMapper=new buyer_invite_codeWapper();
					buyer_invite_code code=codeMapper.selectByExample(example).get(0);	
					Logger.verifyEquals(csb.getInviteCode(), code.getInviteCode(), "验证inviteCode");
					Logger.verifyEquals(csb.getInvitePicUrl(), code.getInvitePicUrl(), "验证invitePicUrl");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
					
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_012() {
		Logger.start(true, "查看客服列表,loginId查询，返回成功");
		try {
			Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
			Logger.comment("创建渠道商客服:" + csId);
			
			GodmchManageCallService.EditCsRemark(mchId, csId, "remakr1");
			listcsBean.setMchId(mchId);
			listcsBean.setLoginId(usercreateBean.getLoginId());
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(1, listcsCall.getJsonObject().get("result").getAsJsonObject().get("total").getAsInt(), "验证total");
			
			listcsCall.getCsBaseVo().forEach(csb -> {
				cs_info csi;
				try {
					csi = DefGodMchWapper.selectCsInfo(listcsBean.getMchId(), csb.getCsId()).get(0);
					Logger.verifyEquals(csb.getTemplateId(), csi.getTempldateId(), "验证TempldateId");
					//Logger.verifyEquals(csb.getRemark(), csi.getRemark(), "验证Remark");
					String title = DefGodMchWapper.selectCsroleByMchId(0).stream().filter(csr -> csr.getRoleId().equals(csb.getTemplateId())).findFirst().get().getTitle();
					Logger.verifyEquals(csb.getTemplateTitle(), title, "验证title");
					
					Logger.verifyEquals(csb.getSetPwd(), false, "验证setPwd");
					Logger.verifyEquals(csb.getTitle(), "", "验证title");
					Logger.verifyEquals(csi.getRemark(), csb.getMemo(), "验证memo");
					
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_013() {
		Logger.start(true, "查看客服列表,loginId不存在，返回成功");
		try {
			Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
			Logger.comment("创建渠道商客服:" + csId);
			
			GodmchManageCallService.EditCsRemark(mchId, csId, "remakr1");
			listcsBean.setMchId(mchId);
			listcsBean.setLoginId("234134134234");
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(0, listcsCall.getJsonObject().get("result").getAsJsonObject().get("total").getAsInt(), "验证total");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_listCS_014() {
		Logger.start(true, "查看客服列表,excludeTemplateId排除的角色模板id(商户有两条客服记录,templateId分别是1和2，排除2)-返回成功 20200623修改");
		try {
			//Integer templateId = 1;
			int mchId=GodmchManageCallService.CreateSellerMch();
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId1 = DGUserCallService.UserCreateCall(usercreateBean);
			usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId2 = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(mchId, csId1, 1);
			GodmchManageCallService.CreateCSCall(mchId, csId2, 2);
			Logger.comment("创建渠道商客服:" + csId1);
			Logger.comment("创建渠道商客服:" + csId2);
			
			GodmchManageCallService.EditCsRemark(mchId, csId1, "remakr1");
			GodmchManageCallService.EditCsRemark(mchId, csId2, "remakr2");
			listcsBean.setMchId(mchId);
			listcsBean.setExcludeTemplateId(1);
			listcsBean.setPageIndex(1);
			listcsBean.setPageSize(10);
			listcsCall.setData(listcsBean);
			listcsCall.callService();
			Logger.verifyEquals("200", listcsCall.getString("status"), "验证status");
			Logger.verifyEquals(1, listcsCall.getCsBaseVo().size(), "验证总数");
			Logger.verifyEquals(csId2, listcsCall.getCsBaseVo().get(0).getCsId(), "验证CsId");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	
	
}